/*
 *    Copyright (c) 2018-2025, bfcloud All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: bfcloud
 */

import request from '@/router/axios'

export function fetchList(query) {
  return request({
    url: '/jiangjin/jiangjinjjxxxb/page',
    method: 'get',
    params: query
  })
}

export function addObj(obj) {
  return request({
    url: '/jiangjin/jiangjinjjxxxb',
    method: 'post',
    data: obj
  })
}

export function getObj(id) {
  return request({
    url: '/jiangjin/jiangjinjjxxxb/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return request({
    url: '/jiangjin/jiangjinjjxxxb/' + id,
    method: 'delete'
  })
}

export function putObj(obj) {
  return request({
    url: '/jiangjin/jiangjinjjxxxb',
    method: 'put',
    data: obj
  })
}

export function getJjDeptJjx(id) {
  return request({
    url: '/jiangjin/jiangjinjjxxxb/getJjDeptJjx/' + id,
    method: 'get'
  })
}
// 批量删除
export function getJjxByjjxfl(query) {
  return request({
    url: '/jiangjin/jiangjinjjxxxb/getJjxByjjxfl',
    method: 'get',
    params: query
  })
}
// 批量删除
export function deleteBatch(query) {
  return request({
    url: '/jiangjin/jiangjinjjxxxb/deleteBatch',
    method: 'get',
    params: query
  })
}

export function jiangjinFqmxb(query) {
  return request({
    url: '/jiangjin/jiangjinFqmxb/page',
    method: 'get',
    params: query
  })
}

export function jiangjinFqmxbSave(obj) {
  return request({
    url: '/jiangjin/jiangjinfqmxcf/save',
    method: 'post',
    data: obj
  })
}

export function getListCf(fId, cfLx) {
  return request({
    url: '/jiangjin/jiangjinfqmxcf/getListCf/' + fId + '/' + cfLx,
    method: 'get',
  })
}

export function saveFZ(obj) {
  return request({
    url: '/jiangjin/jiangjinfqmxcf/saveFZ',
    method: 'post',
    data: obj
  })
}

export function deleteCf(obj) {
  return request({
    url: '/jiangjin/jiangjinfqmxcf/deleteCf',
    method: 'post',
    data: obj
  })
}

export function jiangjinmxcffz(id) {
  return request({
    url: '/jiangjin/jiangjinmxcffz/' + id,
    method: 'delete',
  })
}

export function saveJe(obj) {
  return request({
    url: '/jiangjin/jiangjinmxcffz/saveJe',
    method: 'post',
    data: obj
  })
}

export function updateBmFP(fpId, cfLx) {
  return request({
    url: '/jiangjin/jiangjinfpjjfpdjb/updateBmFP/' + fpId + '/' + cfLx,
    method: 'post',
  })
}

export function updateGrFP(fpId, cfLx,ryName,ryCode,updateFlag) {
  return request({
    url: '/jiangjin/jiangjinfpjjfpdjb/updateGrFP/' + fpId + '/' + cfLx+'/'+ryName+'/'+ryCode+'/'+updateFlag,
    method: 'post',
  })
}

export function updateTjFromTichu(fpId, useSourceType) {
  return request({
    url: '/jiangjin/jiangjinfpjjfpdjb/updateTjFromTichu',
    method: 'post',
    params: {
      fpId: fpId, useSourceType: useSourceType
    }
  })
}


export function downloadTemplate(obj) {
  return request({
    url: '/jiangjin/jiangjinfpjjfpdjb/downloadTemplate',
    method: 'post',
    responseType: 'blob',
    data:obj
  })
}


export function getDXList(fId) {
  return request({
    url: '/jiangjin/jiangjinfqmxcf/getDXList/'+fId,
    method: 'get'
  })
}
export function downloadTemplateForJg(obj) {
  return request({
    url: '/jiangjin/jiangjinfpjjfpdjb/downloadTemplateForJg',
    method: 'post',
    responseType: 'blob',
    data:obj
  })
}

export function saveNotCf(obj) {
  return request({
    url: '/jiangjin/jiangjinfqmxcf/saveNotCf',
    method: 'post',
    data:obj
  })
}

export function exportExcelJiangjinList(obj) {
  
  return request({
    url: '/jiangjin/jiangjinfpjjbmfppzmxb/exportExcelJiangjinList',
    method: 'post',
    data:obj,
    responseType: 'arraybuffer'
  }).then((response) => { // 处理返回的文件流
    const blob = new Blob([response.data], {
      type: 'application/vnd.ms-excel'
    })
    const link = document.createElement('a')
    link.href = URL.createObjectURL(blob)
    link.download = '奖金统计汇总.xlsx'
    document.body.appendChild(link)
    link.click()
    window.setTimeout(function () {
      URL.revokeObjectURL(blob)
      document.body.removeChild(link)
    }, 0)
  })
}

export function getRylistByimport(fpid) {
  return request({
    url: '/jiangjin/jiangjinfpjjfpdjb/getRylistByimport/'+fpid,
    method: 'post',
  })
}

export function downloadBmfpp(fpId) {
  return request({
    url: '/jiangjin/jiangjinfpjjbmfppzmxb/downloadBmfpp/'+fpId,
    method: 'post',
    responseType: 'blob',
  })
}

export function exportExcelRenyuanList(obj) {
  return request({
    url: '/jiangjin/jiangjinfpjjgrfppzmxb/exportExcelRenyuanList',
    method: 'post',
    responseType: 'blob',
    data:obj
  })
}

export function downloadRyfpp(obj) {
  return request({
    url: '/jiangjin/jiangjinfpjjbmfppzmxb/downloadRyfpp/0',
    method: 'post',
    data:obj,
    responseType: 'blob',
  })
}

export function getUserDeptId() {
  return request({
    url: '/jiangjin/jiangjinfpjjbmfppzmxb/getUserDeptId',
    method: 'get',
  })
}

export function getUserDeptInfo() {
  return request({
    url: '/jiangjin/jiangjinfpjjbmfppzmxb/getUserDeptInfo',
    method: 'get',
  })
}

export function isOrNotExcess(query) {
  return request({
    url: '/jiangjin/jiangjinfpjjfpdjb/isOrNotExcess',
    method: 'get',
    params: query
  })
}

export function updateReportTime(obj) {
  return request({
    url: '/jiangjin/jiangjinfpjjfpdjb/updateReportTime',
    method: 'post',
    data: obj
  })
}

export function saveJjc(obj) {
  return request({
    url: '/jiangjin/jiangjinfqmxcf/saveJjc',
    method: 'post',
    data: obj
  })
}


export function getSetting() {
  return request({
    url: '/jiangjin/jiangjinfpjjgrfppzmxb/getSetting',
    method: 'get',
  })
}

export function setting(obj) {
  return request({
    url: '/jiangjin/jiangjinfpjjgrfppzmxb/setting',
    method: 'post',
    data: obj
  })
}

export function uploadEcc(obj) {
  return request({
    url: '/jiangjin/jiangjinfpjjgrfppzmxb/uploadEcc',
    method: 'post',
    data: obj
  })
}